package cn.wzy.utils;

import cn.wzy.common.Result;
import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

/**
 * @author nihaowzy
 * @date 2020/12/22 19:04
 */
public class RespUtil {


    public static void write(HttpServletResponse response , Result result)  {
        response.setContentType("text/json;charset=utf-8");
        try(
                PrintWriter writer = response.getWriter()
        ){
            String data = JSON.toJSONString(result);

            writer.print(data);
            writer.flush();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
